import { PureComponent } from "react"
import { CSSWrapper } from "../style"
import Com1 from "./com1"
import Com2 from "./com2"
// import store from "../../../store";
import { connect } from "react-redux"

class Cpn extends PureComponent {
  // constructor() {
  //     super();
  //     this.state = {
  //         age: store.getState().age,
  //     }
  // }
  // componentDidMount() {
  //     store.subscribe(()=>{
  //         console.log(store.getState().age)
  //         this.setState({ // 强制触发视图更新
  //             age: store.getState().age,
  //         })
  //     })
  // }
  render() {
    const { age } = this.props
    return (
      <div>
        <CSSWrapper>
          <header>Test3 header: {age}</header>
          <div className="flex">
            <div className="flex1">
              <Com1></Com1>
            </div>
            <div className="flex1">
              <Com2></Com2>
            </div>
          </div>
        </CSSWrapper>
      </div>
    )
  }
}

const fn = (state) => {
  return {
    age: state.age
  }
}
export default connect(fn)(Cpn)
